package com.besttone.action;

/**
 * 根据日期查询闪信新增和累计
 *http://localhost:9090/signalAndsms_2_solr/FlashsmsCount?day_id=20170901
 * Created by chenping on 2017/9/7.
 */
import com.besttone.bean.FlashsmsCountBean;
import com.besttone.model.FlashsmsCount;
import com.besttone.util.JsonUtil;
import com.jfinal.core.Controller;
import com.besttone.enums.EnumAPIResultCode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;
public class FlashsmsCountByDayAction extends Controller {
    private static Log _log = LogFactory.getLog(FlashsmsCountByDayAction.class);
    public void index() {
        //String sp_account = getPara("sp_account");
        //String sp_pwd = getPara("sp_pwd");
        String day_id=getPara("day_id");
        try {
            List<FlashsmsCountBean> reList = new ArrayList<FlashsmsCountBean>();
            FlashsmsCountBean UserBean = null;
            List<FlashsmsCount> buttonList = FlashsmsCount.dao.getCntsByDay(day_id);
            for (FlashsmsCount button : buttonList) {
                UserBean = new FlashsmsCountBean();
                UserBean.setBusi_type(button.getStr("busi_type"));
                UserBean.setIncrease_cnts(button.getInt("increase_cnts"));
                UserBean.setAll_cnts(button.getInt("all_cnts"));
                UserBean.setDay_id(button.getStr("day_id"));
                reList.add(UserBean);
            }
            String str = JsonUtil.ObjectToJsonString(reList);
            System.out.println(str);
            setAttr("result_msg", str);
        }catch (Exception e) {
            _log.info("solr查询异常:" + e);
            setAttr("result_code", EnumAPIResultCode.SYSTEM_ERROR.getValue());
            setAttr("result_msg", EnumAPIResultCode.SYSTEM_ERROR.getName());
        }
        renderJson();
        return;
    }
}
